package org.example.bio;

import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Hello world!
 *
 */
public class BioServer
{
    public static void main( String[] args ) throws Exception {
        ServerSocket serverSocket = new ServerSocket();
        // 绑定9090端口
        serverSocket.bind(new InetSocketAddress(9090));
        // 阻塞接受外部连接
        Socket accept = serverSocket.accept();
        while(true) {
            InputStream inputStream = accept.getInputStream();
            byte[] bytes = new byte[10];
            // 阻塞调用
            inputStream.read(bytes);
            System.out.println("服务器端接受的数据是：" + new String(bytes));
        }
    }
}
